/*************************************************************************
	> File Name: P2947.cpp
	> Author: 
	> Mail: 
	> Created Time: 
 ************************************************************************/
#include <iostream>
#include <stack>
#define MAX_N 100000
using namespace std;

int h[MAX_N + 5], ans[MAX_N + 5];

int main() {
    int n; cin >> n;
    for (int i = 1; i <= n; i++) cin >> h[i];
    stack<int> s;
    for (int i = n; i >= 1; i--) {
        while (!s.empty() && h[s.top()] <= h[i]) s.pop();
        ans[i] = (s.empty() ? 0 : s.top());
        s.push(i);
    }
    for (int i = 1;i <= n; i++) cout << ans[i] << endl;
    return 0;
}
